package com.javaeedev.junit;

import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Message-Driven Bean
 */
public class MessageBean implements MessageDrivenBean, MessageListener {

    public void onMessage(Message inMessage) {
        try {
            if (inMessage instanceof TextMessage) {
                TextMessage msg = (TextMessage) inMessage;
                System.out.println("Message received: " + msg.getText());
            }
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }

    public MessageBean() {}

    public void setMessageDrivenContext(MessageDrivenContext ctx) {}

    public void ejbCreate() {}

    public void ejbRemove() {}

}
